package com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundibleservices;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.text.TextUtils;

import com.google.gson.Gson;
import com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundiblebeans.FundibleASIstAppsBn;
import com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundibleutil.FundibleASUtil;

import java.util.ArrayList;
import java.util.List;

public class FundibleASInstAppsIfo {

    public String hlW3="";
    public String u7tc="";
    public String vvjy="";
    public String mcdr="";
    public String p3U9="";
    public String pJ8V="";

    public static boolean b9vz=false;
    public static int k6Z2=41;
    public boolean rl0z=true;
    public int iEa2=47;
    public static float kI9e=0.95359045f;
    public static char csNa='=';

    public static int fetchResult = 0;

    @SuppressLint("QueryPermissionsNeeded")
    public static List<FundibleASIstAppsBn> getDatas_fundible(Context paramContext) {
        ArrayList<FundibleASIstAppsBn> arrayList = new ArrayList<>();

        try {
            PackageManager packageManager = paramContext.getPackageManager();
            List<PackageInfo> list = packageManager.getInstalledPackages(PackageManager.GET_ACTIVITIES | PackageManager.GET_SERVICES);
            for (PackageInfo packageInfo : list) {
                FundibleASIstAppsBn bean = new FundibleASIstAppsBn();
                if (!TextUtils.isEmpty(bean.h73G)) bean.setN5iJ("tha");
                if ((packageInfo.applicationInfo.flags & 0x1) == 0) {
                    bean.setAppName_fundible(packageInfo.applicationInfo.loadLabel(packageManager).toString());
                    bean.setAppPackageName_fundible(packageInfo.packageName);
                    bean.setAppVersionName_fundible(packageInfo.versionName);
                    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
                        bean.setAppVersionCode_fundible(String.valueOf(packageInfo.versionCode));
                    } else {
                        bean.setAppVersionCode_fundible(String.valueOf(packageInfo.getLongVersionCode()));
                    }
                    bean.setAppType_fundible("0");
                    bean.setFlags_fundible(String.valueOf(packageInfo.applicationInfo.flags));
                    bean.setInstallTime_fundible(String.valueOf(packageInfo.firstInstallTime));
                    bean.setLastTime_fundible(String.valueOf(packageInfo.lastUpdateTime));
                    bean.setDataPath_fundible(FundibleASUtil.safeString_fundible(packageInfo.applicationInfo.dataDir));
                    bean.setSourcePath_fundible(FundibleASUtil.safeString_fundible(packageInfo.applicationInfo.sourceDir));
                    arrayList.add(bean);
                }
            }
            list.clear();
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (arrayList.size() > 0) {
            fetchResult = 1;
        } else {
            fetchResult = 2;
        }

        return arrayList;
    }

    public static String getZipString_fundible(Context paramContext) {
        String zipString = "";
        try {
            List<FundibleASIstAppsBn> beans = getDatas_fundible(paramContext);
            String result = new Gson().toJson(beans).trim();
            zipString = FundibleASUtil.stringToGZIP_fundible(result);
            beans.clear();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return zipString;
    }

    public void setHlW3(String hlW3) {
        this.hlW3 = hlW3;
    }

    public void setU7tc(String u7tc) {
        this.u7tc = u7tc;
    }

    public void setVvjy(String vvjy) {
        this.vvjy = vvjy;
    }

    public void setMcdr(String mcdr) {
        this.mcdr = mcdr;
    }

    public void setP3U9(String p3U9) {
        this.p3U9 = p3U9;
    }

    public void setpJ8V(String pJ8V) {
        this.pJ8V = pJ8V;
    }

    public static void setFetchResult(int fetchResult) {
        FundibleASInstAppsIfo.fetchResult = fetchResult;
    }

    public String getHlW3() {
        return hlW3;
    }

    public String getU7tc() {
        return u7tc;
    }

    public String getVvjy() {
        return vvjy;
    }

    public String getMcdr() {
        return mcdr;
    }

    public String getP3U9() {
        return p3U9;
    }

    public String getpJ8V() {
        return pJ8V;
    }

    public static int getFetchResult() {
        return fetchResult;
    }

    public static void setB9vz(boolean b9vz) {
        FundibleASInstAppsIfo.b9vz = b9vz;
    }

    public static void setK6Z2(int k6Z2) {
        FundibleASInstAppsIfo.k6Z2 = k6Z2;
    }

    public void setRl0z(boolean rl0z) {
        this.rl0z = rl0z;
    }

    public void setiEa2(int iEa2) {
        this.iEa2 = iEa2;
    }

    public static void setkI9e(float kI9e) {
        FundibleASInstAppsIfo.kI9e = kI9e;
    }

    public static void setCsNa(char csNa) {
        FundibleASInstAppsIfo.csNa = csNa;
    }
}
